using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NhaThuocOnline.Entities.Mapping
{
    public class HoaDonNhapHangChiTietMap : EntityTypeConfiguration<HoaDonNhapHangChiTiet>
    {
        public HoaDonNhapHangChiTietMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Solo)
                .HasMaxLength(20);

            this.Property(t => t.SoLuong)
                .HasMaxLength(50);

            this.Property(t => t.DonGiaNhap)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("HoaDonNhapHangChiTiet");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SoHoaDon).HasColumnName("SoHoaDon");
            this.Property(t => t.BietDuocId).HasColumnName("BietDuocId");
            this.Property(t => t.HoaDonNhapHangId).HasColumnName("HoaDonNhapHangId");
            this.Property(t => t.Solo).HasColumnName("Solo");
            this.Property(t => t.HSD).HasColumnName("HSD");
            this.Property(t => t.SoLuong).HasColumnName("SoLuong");
            this.Property(t => t.DonGiaNhap).HasColumnName("DonGiaNhap");
            this.Property(t => t.ChietKhau).HasColumnName("ChietKhau");

            // Relationships
            this.HasOptional(t => t.BietDuoc)
                .WithMany(t => t.HoaDonNhapHangChiTiets)
                .HasForeignKey(d => d.BietDuocId);
            this.HasOptional(t => t.HoaDonNhapHang)
                .WithMany(t => t.HoaDonNhapHangChiTiets)
                .HasForeignKey(d => d.HoaDonNhapHangId);

        }
    }
}
